From: Cordell Bloor Date: Wed, 8 Mar 2023 09:57:51 +0000 (-0700) Subject: [PATCH] Search for the bitcode libraries in a multiarch directory X-Git-Tag: archive/raspbian/1%15.0.7-10+rpi1~1^2~9 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=0ec639f76da3700674b8f9da8753e7fa8bdaa1d8;p=llvm-toolchain-15.git [PATCH] Search for the bitcode libraries in a multiarch directory The Debian path for the rocm-device-libs is /usr/lib/$(DEB_HOST_MULTIARCH)/amdgcn/bitcode Forwarded: not-needed Gbp-Pq: Topic amdgpu Gbp-Pq: Name bitcode-multiarch.patch --- diff --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp b/clang/lib/Driver/ToolChains/AMDGPU.cpp index fc47d7f199..2e8e56b39f 100644 --- a/clang/lib/Driver/ToolChains/AMDGPU.cpp +++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp @@ -14,6 +14,7 @@ #include "clang/Driver/DriverDiagnostic.h" #include "clang/Driver/InputInfo.h" #include "clang/Driver/Options.h" +#include "llvm/ADT/Triple.h" #include "llvm/Option/ArgList.h" #include "llvm/Support/Error.h" #include "llvm/Support/FileUtilities.h" @@ -423,16 +424,21 @@ void RocmInstallationDetector::detectDeviceLibrary() { // The possible structures are: // - ${ROCM_ROOT}/amdgcn/bitcode/* // - ${ROCM_ROOT}/lib/* + // - ${ROCM_ROOT}/lib//amdgcn/bitcode/* // - ${ROCM_ROOT}/lib/bitcode/* - // so try to detect these layouts. - static constexpr std::array SubDirsList[] = { - {"amdgcn", "bitcode"}, - {"lib", ""}, - {"lib", "bitcode"}, + // so try to detect these layouts. Note that bitcode is associated with the + // compiler that built it (not the target architecture). + llvm::Triple HostTriple(llvm::sys::getProcessTriple()); + std::string Multiarch = Twine(HostTriple.getArchName() + "-linux-gnu").str(); + static const std::array SubDirsList[] = { + {"amdgcn", "bitcode", "", ""}, + {"lib", "", "", ""}, + {"lib", Multiarch, "amdgcn", "bitcode"}, + {"lib", "bitcode", "", ""}, }; // Make a path by appending sub-directories to InstallPath. - auto MakePath = [&](const llvm::ArrayRef &SubDirs) { + auto MakePath = [&](const llvm::ArrayRef &SubDirs) { auto Path = CandidatePath; for (auto SubDir : SubDirs) llvm::sys::path::append(Path, SubDir);